package com.ants.modules.compressUsageLog.controller;

import com.ants.common.annotation.AutoLog;
import com.ants.common.system.query.QueryGenerator;
import com.ants.common.system.result.Result;
import com.ants.modules.compressUsageLog.entity.CompressUsageLog;
import com.ants.modules.compressUsageLog.service.CompressUsageLogService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * TODO
 * Author Chen
 * Date   2021/9/7 18:44
 */

@Slf4j
@Api(tags = "压缩工具使用记录")
@RestController
@RequestMapping("/compressUsageLog")
public class CompressUsageLogController {

    @Autowired
    CompressUsageLogService compressUsageLogService;

    @AutoLog(value = "压缩工具使用记录-列表")
    @ApiOperation(value = "压缩工具使用记录-列表", notes = "压缩工具使用记录-列表")
    @GetMapping("/list")
    public Result<?> queryPageList(CompressUsageLog compressUsageLog,
                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                   HttpServletRequest req) {
        //String username = StpUtil.getLoginIdAsString();
        QueryWrapper<CompressUsageLog> queryWrapper = QueryGenerator.initQueryWrapper(compressUsageLog, req.getParameterMap());
        //queryWrapper.eq("create_by", username);
        queryWrapper.orderByAsc("sort_no");
        Page<CompressUsageLog> page = new Page<CompressUsageLog>(pageNo, pageSize);
        IPage<CompressUsageLog> pageList = compressUsageLogService.page(page, queryWrapper);
        return Result.ok(pageList);
    }
}
